export function nowDate(type) {
  let date = new Date();
  let year = date.getFullYear(); // 年

  let month = date.getMonth() + 1; // 月
  month = month < 10 ? "0" + month : month;

  let day = date.getDate(); // 日
  day = day < 10 ? "0" + day : day;

  let hour = date.getHours(); // 时
  hour = hour < 10 ? "0" + hour : hour;

  let minutes = date.getMinutes(); // 分
  minutes = minutes < 10 ? "0" + minutes : minutes;

  let seconds = date.getSeconds(); // 秒
  seconds = seconds < 10 ? "0" + seconds : seconds;

  let newDate = ""
  //进行类型的判断
  if (type == "yyyy-MM-dd HH:mm:ss") {
    newDate = year + "-" + month + "-" + day + " " + hour + ":" + minutes + ":" + seconds;
  } else if (type == "yyyy-MM-dd") {
    newDate = year + "-" + month + "-" + day;
  } else if (type == "yyyy年-mm月-dd日") {
    newDate = year + "年" + month + "月" + day+"日";
  }
  return newDate;
}


function GetDate1(day, type) {
  var zdate = new Date();
  var edate;
  if (type === 1) {
    edate = new Date(zdate.getTime() - (day * 24 * 60 * 60 * 1000));
  } else {
    edate = new Date(zdate.getTime() + (day * 24 * 60 * 60 * 1000));
  }
  return edate;
}


/*
*获取传入的日期前N天或后N日期(N = day)
*type:1：前；2：后
*date：传入的日期
*/
function GetDate2(day, type, date) {
  var zdate;
  if (date === null || date === undefined) {
    zdate = new Date();
  } else {
    zdate = date;
  }
  var edate;
  if (type === 1) {
    edate = new Date(zdate.getTime() - (day * 24 * 60 * 60 * 1000));
  } else {
    edate = new Date(zdate.getTime() + (day * 24 * 60 * 60 * 1000));
  }
  return edate;
}
